package com.example.demo.service.impl;

import com.example.demo.mapper.BusinessMapper;
import com.example.demo.pojo.Business;
import com.example.demo.service.BusinessService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
@Service
public class BusinessImpl implements BusinessService {
    @Resource
    BusinessMapper orderMapper;
    @Override
    public List<Business> orderselect(String state, String name, String seq, String begindate, String enddate) {
        List<Business> orderselect=orderMapper.orderselect(state,name,Integer.parseInt(seq),begindate,enddate);
        return orderselect;
    }

    @Override
    public PageInfo<Business> c_StoreShow(Integer page, Integer Size, String statename, String Stropname) {
        PageHelper.startPage(page,Size);
        String add="";
        List<Business> businesses=orderMapper.c_StoreShow(statename,Stropname);
        for(int i=0;i<businesses.size();i++){
            String a= String.valueOf(businesses.get(i).getBuSeq());
            int num =a.length();
            if(num<9){
                int q=9-num;
                for(int j=1;j<=q;j++){
                    add=add+"0";
                }
                businesses.get(i).setCount(businesses.get(i).getBuBusiness()+add+String.valueOf(businesses.get(i).getBuSeq()));
            }
        }
        PageInfo<Business> businessPageInfo =new PageInfo<>(businesses);
        return businessPageInfo;
    }

    @Override
    public String c_StoreUpdate(String stateid, String seq) {
        int a=orderMapper.c_StoreUpdate(Integer.parseInt(stateid),Integer.parseInt(seq));
        return "sucess";
    }

    @Override
    public String c_delete(int seq) {
        orderMapper.c_delete(seq);
        return "sucess";
    }
}
